<!doctype html>
{% import 'macro/svg.html' as SVG %}
{% import 'macro/oops.html' as OOPS %}
{% import 'macro/head.html' as HEAD %}
<html lang="en">
<head>
  {{ HEAD.meta_link() }}
  <title>NAStool</title>
  <!-- CSS files -->
  <link href="../static/css/tabler.min.css" rel="stylesheet"/>
  <link href="../static/css/demo.min.css" rel="stylesheet"/>
  <link href="../static/css/tabler-vendors.min.css" rel="stylesheet"/>
  <link href="../static/css/fullcalendar.min.css" rel="stylesheet"/>
  <link href="../static/css/jquery.filetree.css" rel="stylesheet"/>
  <link href="../static/css/dropzone.css" rel="stylesheet"/>
  <link href="../static/css/nprogress.css" rel="stylesheet"/>
  <!-- 附加样式 -->
  <link href="../static/css/style.css" rel="stylesheet"/>
  <!-- 站点图标 -->
  <style>
  .siteicon-acgrip {
      background: url(../static/img/sites/acgrip.ico);
      background-size: cover;
      border: 0;
  }
  .siteicon-dmhy {
      background: url(../static/img/sites/dmhy.ico);
      background-size: cover;
      border: 0;
  }
  .siteicon-eztv {
      background: url(../static/img/sites/eztv.ico);
      background-size: cover;
      border: 0;
  }
  .siteicon-mikanani {
      background: url(../static/img/sites/mikanani.ico);
      background-size: cover;
      border: 0;
  }
  .siteicon-nyaa {
      background: url(../static/img/sites/nyaa.png);
      background-size: cover;
      border: 0;
  }
  .siteicon-rarbg {
      background: url(../static/img/sites/rarbg.ico);
      background-size: cover;
      border: 0;
  }
  .siteicon-torrentgalaxy {
      background: url(../static/img/sites/torrentgalaxy.png);
      background-size: cover;
      border: 0;
  }
  {% for site_name, site_icon in SiteFavicons.items() %}
  .siteicon-{{ site_name|hash }} {
      background-image: url({{ site_icon }});
      background-size: cover;
      border: 0;
  }
  {% endfor %}
  </style>
</head>
<body class="layout-fluid">
<div class="page">
  <!-- jquery -->
  <script src="../static/js/jquery-3.3.1.min.js"></script>
  <script src="../static/js/tabler/demo-theme.min.js"></script>
  <!-- 第三方组件 -->
  <script src="../static/js/modules/echarts.min.js"></script>
  <script src="../static/js/modules/nprogress.js"></script>
  <script src="../static/js/modules/dom-to-image.min.js"></script>
  <script src="../static/js/modules/FileSaver.min.js"></script>
  <script src="../static/js/modules/numeral.min.js"></script>
  <script src="../static/js/modules/moment.min.js"></script>
  <script src="../static/js/modules/jquery.filetree.js"></script>
  <script src="../static/js/ace/ace.js"></script>
  <script src="../static/js/fullcalendar/fullcalendar.min.js"></script>
  <script src="../static/js/fullcalendar/locales/zh-cn.js"></script>
  <script src="../static/js/modules/reconnecting-websocket.js"></script>
  <!-- lit -->
  <script type="module" src="../static/components/lit-index.js"></script>
  <!-- 解决密码填充问题 -->
  <span hidden><input type="text" aria-label=""><input type="password" aria-label=""></span>
  <layout-navbar id="navbar-menu" hidden
    layout-userlevel="{{ CurrentUser.level }}"
    layout-useradmin="{{ CurrentUser.admin }}"
    layout-gopage="{{ GoPage }}"
    layout-appversion="{{ AppVersion }}"
    >
  </layout-navbar>
  <layout-searchbar hidden
      layout-username="{{ CurrentUser.name }}"
      layout-systemflag="{{ SystemFlag }}"
      layout-useradmin="{{ CurrentUser.admin }}"
      layout-search="{{ CurrentUser.search }}"
      >
  </layout-searchbar>
  <div class="spinner-border" role="status" id="logo_animation"></div>
  <div class="page-wrapper" >
    <div id="page_content" hidden="">
    {{ OOPS.loading() }}
    </div>
  </div>
  <div id="main_bottom_menubar" class="position-fixed w-100 d-flex justify-content-between d-sm-none main-bottom-menubar d-none">
    {% if "我的媒体库" in CurrentUser.pris %}
    <a class="card-btn border-0 px-0 text-center" href="javascript:navmenu('index')">
      {{ SVG.home() }}
    </a>
    {% endif %}
    {% if "探索" in CurrentUser.pris %}
    <a class="card-btn border-0 px-0 text-center" href="javascript:navmenu('ranking')">
      {{ SVG.chart_bar() }}
    </a>
    {% endif %}
    {% if "服务" in CurrentUser.pris %}
    <a class="card-btn border-0 px-0 text-center" href="javascript:navmenu('service')">
      {{ SVG.layout_2() }}
    </a>
    {% endif %}
    {% if "订阅管理" in CurrentUser.pris %}
    <a class="card-btn border-0 px-0 text-center" href="javascript:navmenu('movie_rss')">
      {{ SVG.movie() }}
    </a>
    <a class="card-btn border-0 px-0 text-center" href="javascript:navmenu('tv_rss')">
      {{ SVG.device_tv() }}
    </a>
    {% endif %}
  </div>
</div>
<div class="offcanvas offcanvas-end" tabindex="-1" id="offcanvasEnd" aria-labelledby="消息中心">
  <div class="offcanvas-header">
    <h2 class="offcanvas-title" id="offcanvasEndLabel">消息中心</h2>
    <button type="button" class="btn-close text-reset" data-bs-dismiss="offcanvas" aria-label="Close"></button>
  </div>
  <div class="offcanvas-body p-1" style="margin-bottom: calc(50px + env(safe-area-inset-top) + env(safe-area-inset-bottom))">
    <div class="list-group list-group-flush" id="system-messages">
    </div>
    <div class="mt-3 w-100 position-absolute mb-2 pe-2" align="center" style="bottom: calc(env(safe-area-inset-bottom))">
      <div class="input-group">
        <button type="button" class="btn" data-bs-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
          /
        </button>
        <div class="dropdown-menu" data-popper-placement="bottom-start">
          {% for Command in Commands %}
          <a class="dropdown-item" href="javascript:send_web_message('{{ Command.id }}')">
            {{ Command.name }}
          </a>
          {% endfor %}
        </div>
        <input type="text" id="message_center_input" class="form-control" autocomplete="off" placeholder="输入消息或命令..."
            onkeydown="if(event.keyCode==13) send_web_message($(this))">
        <button class="btn btn-primary" type="button" onclick="send_web_message($('#message_center_input'))">发送</button>
      </div>
    </div>
  </div>
</div>
<!-- 等待框 -->
<div class="modal" id="modal-wait" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-full-width modal-dialog-centered" role="document">
    <div class="spinner-border text-primary m-auto" style="width:40px;height:40px;"></div>
  </div>
</div>
<!-- 进度框 -->
<div class="modal modal-blur" id="modal-process" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-md modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="card border-0">
        <div class="progress rounded-0">
          <div class="progress-bar progress-bar-striped progress-bar-animated" id="modal_process_bar"
               style="width: 0" role="progressbar" aria-valuenow="0" aria-valuemin="0" aria-valuemax="100"></div>
        </div>
        <div class="card-body text-center">
          <h3 class="card-title strong" id="modal_process_title">
          </h3>
          <small class="text-muted" id="modal_process_text">请稍候...</small>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 危险确认提示框 -->
<div class="modal modal-blur fade" id="system-confirm-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      <div class="modal-status bg-danger"></div>
      <div class="modal-body text-center py-4">
       <span class="mb-2 text-danger">{{ SVG.alert_triangle('icon-lg') }}</span>
        <h3>确认</h3>
        <div class="text-muted text-wrap" id="system_confirm_message">是否确定？</div>
      </div>
      <div class="modal-footer">
        <div class="w-100">
          <div class="row">
            <div class="col">
              <a href="#" class="btn w-100" data-bs-dismiss="modal">
                取消
              </a>
            </div>
            <div class="col">
              <button class="btn btn-danger w-100" id="system_confirm_btn">
                确定
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 成功带后续操作提示框 -->
<div class="modal modal-blur fade" id="system-success-action-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      <div class="modal-status bg-success"></div>
      <div class="modal-body text-center py-4">
        <span class="mb-2 text-green">{{ SVG.circle_check('icon-lg') }}</span>
        <h3>成功</h3>
        <div class="text-muted text-wrap" id="system_success_action_message">操作成功！</div>
      </div>
      <div class="modal-footer">
        <div class="w-100">
          <div class="row">
            <div class="col" id="system_success_action_div">
              <button class="btn w-100" id="system_success_action_btn">
                操作
              </button>
            </div>
            <div class="col">
              <button class="btn btn-success w-100" data-bs-dismiss="modal">
                确定
              </button>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 询问框 -->
<div class="modal modal-blur fade" id="system-ask-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-body">
        <div class="modal-title">询问</div>
        <div id="system_ask_message" class="text-wrap">是否执行？</div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-link link-secondary me-auto" data-bs-dismiss="modal">取消</button>
        <button type="button" class="btn btn-danger" id="system_ask_btn">确定</button>
      </div>
    </div>
  </div>
</div>
<!-- 成功提示 -->
<div class="modal modal-blur fade" id="system-success-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      <div class="modal-status bg-success"></div>
      <div class="modal-body text-center py-4">
        <span class="mb-2 text-green">{{ SVG.circle_check('icon-lg') }}</span>
        <h3>成功</h3>
        <div class="text-muted text-wrap" id="system_success_message">成功！</div>
      </div>
      <div class="modal-footer">
        <div class="w-100">
          <div class="row">
            <div class="col">
              <a href="javascript:void(0)" id="system_success_modal_btn" class="btn btn-success w-100"
                 data-bs-dismiss="modal">
                确定
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 失败提示 -->
<div class="modal modal-blur fade" id="system-fail-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      <div class="modal-status bg-danger"></div>
      <div class="modal-body text-center py-4">
        <span class="mb-2 text-danger">{{ SVG.alert_triangle('icon-lg') }}</span>
        <h3>失败</h3>
        <div class="text-muted text-wrap" id="system_fail_message">错误信息</div>
      </div>
      <div class="modal-footer">
        <div class="w-100">
          <div class="row">
            <div class="col">
              <a href="#" id="system_fail_modal_btn" class="btn btn-danger w-100" data-bs-dismiss="modal">
                确定
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 警告提示 -->
<div class="modal modal-blur fade" id="system-warning-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-sm modal-dialog-centered" role="document">
    <div class="modal-content">
      <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      <div class="modal-status bg-warning"></div>
      <div class="modal-body text-center py-4">
        <span class="mb-2 text-warning">{{ SVG.alert_triangle('icon-lg') }}</span>
        <h3>注意</h3>
        <div class="text-muted text-wrap" id="system_warning_message">警告信息</div>
      </div>
      <div class="modal-footer">
        <div class="w-100">
          <div class="row">
            <div class="col">
              <a href="#" id="system_warning_modal_btn" class="btn btn-warning w-100" data-bs-dismiss="modal">
                确定
              </a>
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 媒体详情 -->
<div class="modal modal-blur fade" id="system-media-modal" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="card">
        <div class="ribbon ribbon-top ribbon-bookmark bg-purple" id="system_media_vote"></div>
        <div class="row row-0">
          <div class="col-3 d-none d-lg-block">
            <custom-img id="system_media_poster"
                img-class="w-100 h-100 object-cover rounded-2"
                img-ratio="150%"
            ></custom-img>
          </div>
          <div class="col">
            <div class="card-body">
              <h4 class="card-title mb-3">
                <a id="system_media_name_link" href="#" target="_blank"><strong
                        id="system_media_name"></strong></a><br/>
                <span class="text-muted" id="system_release_date"></span>
              </h4>
              <div class="text-muted mb-3" id="system_media_overview">
              </div>
              <div id="system_sites_info"></div>
            </div>
          </div>
        </div>
        <div class="d-flex">
          <a href="#" class="card-btn" id="system_media_url_btn">
            详情
          </a>
          <a href="javascript:void(0)" data-bs-toggle="dropdown" class="dropdown-toggle card-btn"
             id="system_media_rss_btn">
            订阅
          </a>
          <div class="dropdown-menu" id="system_media_rss_dropdown"></div>
          <a href="javascript:void(0)" class="card-btn" id="system_media_search_btn"
             style="border-left:1px solid var(--tblr-border-color)">
            搜索
          </a>
          <a href="javascript:void(0)" class="card-btn" id="system_media_refresh_btn"
             style="border-left:1px solid var(--tblr-border-color)">
            刷新
          </a>
          <a href="javascript:void(0)" class="card-btn d-none d-md-block" data-bs-dismiss="modal">
            关闭
          </a>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 实时日志 -->
<div class="modal modal-blur fade" id="modal-logging" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-xl modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <div class="select_logger">
          <h5 class="modal-title">实时日志</h5>
           <div class="dropdown">
              <button class="btn-action" data-bs-toggle="dropdown" aria-expanded="false">
                {{ SVG.log_select() }}
              </button>
              <div class="dropdown-menu dropdown-menu-end" id="dropdown-menu-logger">
              {% with Loggers = ['All', 'System', 'Rss', 'RssChecker', 'Rmt', 'Meta', 'Sync', 'Sites', 'Brush', 'Douban', 'Spider', 'Message', 'Indexer', 'Searcher', 'Subscribe', 'Downloader', 'TorrentRemover', 'Plugin'] %}
                {% for Logger in Loggers %}
                <a class="dropdown-item" href="javascript:void(0)" onclick="logger_select('{{ Logger }}')">{{ Logger }}</a>
                {% endfor %}
              {% endwith %}
              </div>
           </div>
        </div>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div id="logging_table" class="table-responsive table-modal-body">
      <table class="table table-vcenter card-table table-hover table-striped">
        <thead>
          <tr>
            <th class="w-3">时间</th>
            <th class="w-3">来源</th>
            <th>内容</th>
          </tr>
        </thead>
        <tbody id="logging_content" class="table-tbody">
          <tr><td colspan="3" class="text-center">刷新中...</td></tr>
        </tbody>
      </table>
      </div>
      <div class="modal-footer">
        <a href="javascript:pause_logging()" class="btn btn-link me-auto" id="logging_stop_btn">暂停</a>
        <button type="button" class="btn btn-primary" data-bs-dismiss="modal">关闭</button>
      </div>
    </div>
  </div>
</div>
<!-- 订阅季 -->
<div class="modal modal-blur fade" id="system-rss-seasons" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">选择订阅季</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col">
            <div class="mb-3">
              <div class="form-selectgroup" id="system_rss_seasons_group">
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <a href="javascript:void(0)" id="system_rss_seasons_btn" class="btn btn-primary">确定</a>
      </div>
    </div>
  </div>
</div>
<div class="modal modal-blur fade" id="modal-default-rss-setting" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
      <div class="modal-header">
          <h5 class="modal-title" >订阅默认设置 <span class="form-help"
                                                            title="订阅默认设置，只适用于探索页面、交互消息、豆瓣、Jellyseerr/Overseerr等自动订阅场景"
                                                            data-bs-toggle="tooltip">?</span></h5>
          <input type="hidden" id="default_rss_setting_mtype">
          <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"
                  id="default_sites_close_btn"></button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">质量</label>
              <select class="form-select" id="default_rss_setting_restype">
                <option value="" selected>全部</option>
                {% for Restype in RestypeDict %}
                  <option value="{{ Restype }}">{{ Restype }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">分辨率</label>
              <select class="form-select" id="default_rss_setting_pix">
                <option value="" selected>全部</option>
                {% for Pix in PixDict %}
                  <option value="{{ Pix }}">{{ Pix }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">制作组/字幕组</label>
              <input type="text" id="default_rss_setting_team" class="form-control" placeholder="支持正则表达式">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">包含 <span class="form-help"
                                                       title="只有种子标题或副标题中包含对应关键字或匹配对应正则表达式的才会被选中"
                                                       data-bs-toggle="tooltip">?</span></label>
              <input type="text" value="" id="default_rss_setting_include" class="form-control" placeholder="关键字或正则表达式">
            </div>
          </div>
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">排除 <span class="form-help"
                                                       title="种子标题或副标题中包含对应关键字或匹配对应正则表达式的将会被过滤掉"
                                                       data-bs-toggle="tooltip">?</span></label>
              <input type="text" value="" id="default_rss_setting_exclude" class="form-control" placeholder="关键字或正则表达式">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">过滤规则 </label>
              <select class="form-select" id="default_rss_setting_rule"></select>
            </div>
          </div>
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">下载设置</label>
              <select class="form-select" id="default_rss_setting_download_setting"></select>
            </div>
          </div>
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">洗版 </label>
              <select class="form-select" id="default_rss_setting_over_edition">
                <option value="0" selected>否</option>
                <option value="1">是</option>
              </select>
            </div>
          </div>
        </div>
        <div class="row rss_sites_container" id="default_rss_setting_rss_sites_div">
          <div class="mb-3">
              <div class="btn-list">
                  <label class="form-label">订阅站点</label>
                  <a href="javascript:void(0)" class="ms-auto"
                     onclick="select_btn_SelectALL(this, 'default_rss_sites')">全选</a>
              </div>
              <div class="form-selectgroup" id="default_rss_setting_rss_sites_group"></div>
          </div>
        </div>
        <div class="row rss_sites_container" id="default_rss_setting_search_sites_div">
          <div class="mb-3">
              <div class="btn-list">
                  <label class="form-label">搜索站点</label>
                  <a href="javascript:void(0)" class="ms-auto"
                     onclick="select_btn_SelectALL(this, 'default_search_sites')">全选</a>
              </div>
              <div class="form-selectgroup" id="default_rss_setting_search_sites_group"></div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button onclick="save_default_rss_setting()" class="btn btn-primary">保存</button>
      </div>
    </div>
  </div>
</div>
<!-- 手动订阅 -->
<div class="modal modal-blur fade" id="modal-manual-rss" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="rss_modal_title">新增订阅</h5>
        <input type="hidden" id="rss_id">
        <input type="hidden" id="rss_type">
        <input type="hidden" id="rss_tmdbid">
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-lg-6">
            <div class="mb-3">
              <label class="form-label required">标题</label>
              <input type="text" value="" id="rss_name" class="form-control" placeholder="标题">
            </div>
          </div>
          <div class="col-lg-2">
            <div class="mb-3">
              <label class="form-label required">年份</label>
              <input type="text" value="" id="rss_year" class="form-control" placeholder="年份">
            </div>
          </div>
          <div class="col-lg-4">
            <div class="mb-3">
              <label class="form-label">自定义搜索词</label>
              <input type="text" value="" id="rss_keyword" class="form-control" placeholder="留空使用TMDB数据">
            </div>
          </div>
        </div>
        <div class="row" id="rss_tv_season_div">
          <div class="col-lg-4">
            <div class="mb-3">
              <label class="form-label required">季</label>
              <select class="form-select" id="rss_season">
                <option value="" selected>请选择</option>
                {% for i in range(1, 51) %}
                  <option value="{{ i }}">第{{ i }}季</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="mb-3">
              <label class="form-label">总集数 <span class="form-help"
                                                     title="可留空应用TMDB剧集信息"
                                                     data-bs-toggle="tooltip">?</span></label>
              <input type="text" value="" id="rss_total_ep" class="form-control" placeholder="总集数">
            </div>
          </div>
          <div class="col-lg-4">
            <div class="mb-3">
              <label class="form-label">开始订阅集数</label>
              <input type="text" value="" id="rss_current_ep" class="form-control" placeholder="开始订阅集数">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-xl-4">
            <div class="mb-3">
              <label class="form-check form-switch">
                <input class="form-check-input" type="checkbox" id="fuzzy_match"
                       onclick="change_match_check(this)">
                <span class="form-check-label">模糊匹配 <span class="form-help"
                                                              title="开启后不检查TMDB是否有媒体信息，只要种子名称、标题、年份任一匹配关键字即会下载，此时标题可以配置正则表达式实现模糊匹配"
                                                              data-bs-toggle="tooltip">?</span></span>
              </label>
            </div>
          </div>
          <div class="col-xl-4">
            <div class="mb-3">
              <label class="form-check form-switch">
                <input class="form-check-input" type="checkbox" id="over_edition"
                       onclick="change_over_edition_check(this)">
                <span class="form-check-label">洗版 <span class="form-help"
                                                          title="开启洗版后不会检查本地是否已存在，满足订阅条件即会下载；除非匹配了对应的过滤规则中最高优先级的那条规则否则不会删除订阅（未明确过滤规则时使用默认规则），同一优先级的资源只下载一次；多个资源下载后如命名一致，则只会保留文件体积较大的，如需都保留则需要在文件重命名规则中增加相关要素以做区分"
                                                          data-bs-toggle="tooltip">?</span></span>
              </label>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-3">
            <div class="mb-3">
              <label class="form-label">质量</label>
              <select class="form-select" id="rss_restype">
                <option value="" selected>全部</option>
                {% for Restype in RestypeDict %}
                  <option value="{{ Restype }}">{{ Restype }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg-3">
            <div class="mb-3">
              <label class="form-label">分辨率</label>
              <select class="form-select" id="rss_pix">
                <option value="" selected>全部</option>
                {% for Pix in PixDict %}
                  <option value="{{ Pix }}">{{ Pix }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg-3">
            <div class="mb-3">
              <label class="form-label">制作组/字幕组</label>
              <input type="text" value="" id="rss_team" class="form-control" placeholder="支持正则表达式">
            </div>
          </div>
          <div class="col-lg-3">
            <div class="mb-3">
              <label class="form-label">过滤规则 <span class="form-help"
                                                       title="质量、分辨率与过滤规则为“与”的关系，过滤规则不选择时将使用站点的过滤规则，站点也未设置过滤规则时将使用默认过滤规则"
                                                       data-bs-toggle="tooltip">?</span></label>
              <select class="form-select" id="rss_rule">
              </select>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">包含 <span class="form-help"
                                                       title="只有种子标题或副标题中包含对应关键字或匹配对应正则表达式的才会被选中"
                                                       data-bs-toggle="tooltip">?</span></label>
              <input type="text" value="" id="rss_include" class="form-control" placeholder="关键字或正则表达式">
            </div>
          </div>
          <div class="col-lg">
            <div class="mb-3">
              <label class="form-label">排除 <span class="form-help"
                                                       title="种子标题或副标题中包含对应关键字或匹配对应正则表达式的将会被过滤掉"
                                                       data-bs-toggle="tooltip">?</span></label>
              <input type="text" value="" id="rss_exclude" class="form-control" placeholder="关键字或正则表达式">
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-4">
            <div class="mb-3">
              <label class="form-label">下载设置</label>
              <select class="form-select" id="rss_download_setting"
                      onchange="refresh_savepath_select('rss_save_path', true, $(this).val())">
              </select>
            </div>
          </div>
          <div class="col-lg-8">
            <div class="mb-3">
              <label class="form-label">保存路径</label>
              <select class="form-select" id="rss_save_path" aria-label="保存目录" onchange="check_manual_input_path('rss_save_path','rss_save_path_manual')">
              </select>
              <input type="text" value="" id="rss_save_path_manual" class="form-control" style="display: none" placeholder="留空自动选择保存路径">
            </div>
          </div>
        </div>
        <div class="row rss_sites_container" id="rss_sites_div">
          <div class="mb-3">
            <div class="btn-list">
              <label class="form-label">订阅站点</label>
              <a href="javascript:void(0)" class="ms-auto" onclick="select_btn_SelectALL(this, 'rss_sites')">全选</a>
            </div>
            <div class="form-selectgroup" id="rss_sites_group"></div>
          </div>
        </div>
        <div class="row rss_sites_container" id="rss_search_sites_div">
          <div class="mb-3">
            <div class="btn-list">
              <label class="form-label">搜索站点</label>
              <a href="javascript:void(0)" class="ms-auto" onclick="select_btn_SelectALL(this, 'search_sites')">全选</a>
            </div>
            <div class="form-selectgroup" id="rss_search_sites_group"></div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <a href="#" class="btn btn-link text-red me-auto" id="rss_delete_btn">
          取消订阅
        </a>
        <div class="btn-list">
          <a href="javascript:add_rss_manual(true)" name="rss_add_btn" class="btn btn-secondary">添加并继续</a>
          <a href="javascript:add_rss_manual(false)" name="rss_add_btn" class="btn btn-primary">添加</a>
          <a href="javascript:add_rss_manual(false)" name="rss_edit_btn" class="btn btn-primary">确定</a>
        </div>
      </div>
    </div>
  </div>
</div>
<!-- 手动识别 -->
<div class="modal modal-blur fade" id="modal-media-identification" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title" id="rename_header">手动识别</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="row" id="rename_path_div">
          <div class="col-lg-9">
            <div class="mb-3">
              <label class="form-label required">路径</label>
              <input type="text" id="rename_path" class="form-control" readonly>
              <input type="hidden" id="rename_source">
              <input type="hidden" id="rename_manual_type">
              <input type="hidden" id="unknown_id">
              <input type="hidden" id="transferlog_id" class="form-control">
            </div>
          </div>
          <div class="col-lg-3">
            <div class="mb-3">
              <label class="form-label required">转移方式</label>
              <select id="rename_syncmod_manual" class="form-select">
                {% for mode in RmtModeDict %}
                  <option value="{{ mode.value }}" {% if SyncMod==mode.value %}selected{% endif %}>{{ mode.name }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
        </div>
        <div class="mb-3" id="rename_inpath_div">
          <label class="form-label required">输入路径</label>
          <input type="text" id="rename_inpath" class="form-control filetree-folders-only"
                 placeholder="需要转移的目录或文件"
                 autocomplete="off">
        </div>
        <div class="row" id="rename_outpath_div">
          <div class="col-lg-9">
            <div class="mb-3">
              <label class="form-label">输出路径</label>
              <input type="text" id="rename_outpath" class="form-control filetree-folders-only"
                     placeholder="转移后文件存储路径，留空则转移至媒体库" autocomplete="off">
            </div>
          </div>
          <div class="col-lg-3">
            <div class="mb-3">
              <label class="form-label required">转移方式</label>
              <select id="rename_syncmod_customize" class="form-select">
                {% for mode in RmtModeDict %}
                  <option value="{{ mode.value }}" {% if SyncMod==mode.value %}selected{% endif %}>{{ mode.name }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
        </div>
        <label class="form-label">类型</label>
        <div class="form-selectgroup-boxes row mb-3">
          <div class="col-lg-4">
            <div class="mb-1">
              <label class="form-selectgroup-item">
                <input type="radio" id="rename_type_mov" name="rename_type" value="MOV" class="form-selectgroup-input" onchange="switch_rename_type(this)"
                       checked>
                <span class="form-selectgroup-label d-flex align-items-center p-3">
                    <span class="me-3">
                      <span class="form-selectgroup-check"></span>
                    </span>
                    <span class="form-selectgroup-label-content">
                      <span class="form-selectgroup-title strong mb-1">电影</span>
                    </span>
                  </span>
              </label>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="mb-1">
              <label class="form-selectgroup-item">
                <input type="radio" id="rename_type_tv" name="rename_type" value="TV" onchange="switch_rename_type(this)" class="form-selectgroup-input">
                <span class="form-selectgroup-label d-flex align-items-center p-3">
                    <span class="me-3">
                      <span class="form-selectgroup-check"></span>
                    </span>
                    <span class="form-selectgroup-label-content">
                      <span class="form-selectgroup-title strong mb-1">电视剧</span>
                    </span>
                  </span>
              </label>
            </div>
          </div>
          <div class="col-lg-4">
            <div class="mb-1">
              <label class="form-selectgroup-item">
                <input type="radio" id="rename_type_anime" name="rename_type" value="ANIME" onchange="switch_rename_type(this)"
                       class="form-selectgroup-input">
                <span class="form-selectgroup-label d-flex align-items-center p-3">
                    <span class="me-3">
                      <span class="form-selectgroup-check"></span>
                    </span>
                    <span class="form-selectgroup-label-content">
                      <span class="form-selectgroup-title strong mb-1">动漫</span>
                    </span>
                  </span>
              </label>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-lg-4">
            <div class="mb-3">
              <label class="form-label">TMDB ID</label>
              <div class="input-group">
                <input type="text" id="rename_tmdb" class="form-control" placeholder="留空自动识别">
                <button class="btn" type="button" onclick="show_search_tmdbid_modal('rename_tmdb', 'modal-media-identification')">查询</button>
              </div>
            </div>
          </div>
          <div class="col-lg-4" id="rename_season_div">
            <div class="mb-3">
              <label class="form-label">季</label>
              <select class="form-select" id="rename_season">
                <option value="" selected>请选择</option>
                {% for i in range(0, 51) %}
                  <option value="{{ i }}">第{{ i }}季</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-lg-4" id="rename_min_filesize_div">
            <div class="mb-3">
              <label class="form-label">最小文件大小 <span class="form-help" title="留空将使用基础设置中的转移最小文件大小设置，如不限制大小需输入0" data-bs-toggle="tooltip">?</span></label>
              <input type="text" id="rename_min_filesize" class="form-control" placeholder="最小文件大小(MB)">
            </div>
          </div>
          <div class="col-lg-12" id="rename_specify_episode_div">
            <div class="mb-3">
              <label class="form-label">集数指定 <span class="form-help"
                                                       title="2个都不填，用默认识别 <br>1、指定具体集数 <br>&nbsp;&nbsp;&nbsp;&nbsp;例如 '1' 表示第一集, '1-2'表示第1-2集(1,2合起来当作一集)，此选项优先级最高。<br>2、part: 需符合以下正则写法(PART[0-9ABCI]{0,2}|^CD[0-9]{0,2}|^DVD[0-9]{0,2}|^DISK[0-9]{0,2}|^DISC[0-9]{0,2})：例如Part1, PartC, PartIII, Cd1, Dvd2, Disk10, Disc12"
                                                       data-bs-toggle="tooltip" data-bs-html="true">?</span></label>
              <div class="row">
                <div class="col-4">
                  <input type="text" id="rename_specify_episode" class="form-control" placeholder="指定集数">
                </div>
                <div class="col-4">
                  <input type="text" id="rename_specify_part" class="form-control"
                         placeholder="指定Part">
                </div>
              </div>
            </div>
          </div>
          <div class="col-lg-12" id="rename_episode_div">
            <div class="mb-3">
              <label class="form-label">高级集数定位 <span class="form-help"
                                                       title="3个都不填，用默认识别<br>1、{ep}: 标定集数位置，例如：<br>&nbsp;&nbsp;&nbsp;&nbsp;'(BD)十二国記 第45話「東の海神 西の滄海 五章」(1440x1080 x264-10bpp flac).mkv'<br>&nbsp;&nbsp;&nbsp;&nbsp;'(BD)十二国記 第32話「風の万里 黎明の空　九章」(1440x1080 x264-10bpp flac).mkv'<br>&nbsp;&nbsp;&nbsp;&nbsp;此处可以填'(BD)十二国記 第{ep}話{a}(1440x1080 x264-10bpp flac).mkv' ep表示集，a表示理解成一个变量，随意用一个变量表示，如果没有变化的部分，只标定ep就行。<br>2、起始集,终止集：裁定处理集数过滤范围，<br>&nbsp;&nbsp;&nbsp;&nbsp;例如'2,4' 只取第2集到第4集。<br>3、集数偏移：例如ep定位出集数是11, 实际是第1集, 此处填-10, 以应付多季合集的场景。"
                                                       data-bs-toggle="tooltip" data-bs-html="true">?</span></label>
              <div class="row">
                <div class="col-4">
                  <input type="text" id="rename_episode" class="form-control" placeholder="{ep}定位集数">
                </div>
                <div class="col-4">
                  <input type="text" id="rename_episode_details" class="form-control"
                         placeholder="起始集,终止集，如1,2">
                </div>
                <div class="col-4">
                  <input type="text" id="rename_episode_offset" class="form-control" placeholder="集数偏移，如-10">
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-link me-auto" data-bs-dismiss="modal">取消</button>
        <button type="button" id="identification_action_btn" class="btn btn-primary"
                onclick="manual_media_transfer()">转移
        </button>
      </div>
    </div>
  </div>
</div>
<!-- 手动下载 -->
<div class="modal modal-blur fade" id="modal-search-download" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-md modal-dialog-centered" role="document">
    <input type="hidden" id="search_download_id">
    <input type="hidden" id="search_download_name">
    <div class="modal-content">
      <div class="modal-body">
        <div class="modal-title">添加下载</div>
        <div class="row mt-3">
          <div class="col-md">
            <div class="form-floating mb-1">
              <select class="form-select" id="search_download_setting" aria-label="下载设置"
                  onchange="refresh_savepath_select('search_download_dir', true, $(this).val())">
              </select>
              <label for="search_download_setting">下载设置</label>
            </div>
          </div>
          <div class="col-md">
            <div class="form-floating mb-1">
              <select class="form-select" id="search_download_dir" aria-label="保存目录" onchange="check_manual_input_path('search_download_dir', 'search_download_dir_manual')"></select>
              <input type="text" value="" id="search_download_dir_manual" class="form-control" style="display: none" placeholder="留空自动选择保存路径">
              <label for="search_download_dir">保存目录</label>
            </div>
          </div>
        </div>
        <form class="dropzone mt-2" id="torrent_files" action="/upload">
          <div class="fallback">
            <input name="file" type="file" accept="*.zip" />
          </div>
          <div class="dz-message">
            <h3 class="dropzone-msg-title">上传种子文件</h3>
            <span class="dropzone-msg-desc">点击或者拖动种子文件到此处</span>
          </div>
        </form>
        <textarea class="form-control mt-2" id="torrent_urls" rows="8" placeholder="https://xxxx，换行添加多个链接" aria-label=""></textarea>
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-link link-secondary me-auto" data-bs-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" id="search_download_btn" title="立即开始下载">
          下载
        </button>
      </div>
    </div>
  </div>
</div>
<!-- 根据名称查找TMDBID的对话框 -->
<div class="modal modal-blur fade" id="search-tmdbid-modal" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">查询TMDBID</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col">
            <input id="search_tmdbid_name" type="text" class="form-control" placeholder="输入名称查询" onkeydown="if(event.keyCode==13) search_tmdbid_by_name('search_tmdbid_name', 'search_tmdbid_list')">
          </div>
          <div class="col-auto">
            <button onclick="search_tmdbid_by_name('search_tmdbid_name', 'search_tmdbid_list')" class="btn btn-primary btn-icon" aria-label="Button">
              {{ SVG.search() }}
            </button>
          </div>
        </div>
        <div class="row mt-3">
          <div class="list-group list-group-flush" id="search_tmdbid_list">
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button id="search_tmdbid_btn" class="btn btn-primary">确定</button>
      </div>
    </div>
  </div>
</div>
<div class="modal modal-blur fade" id="modal-search-advanced" tabindex="-1" role="dialog" aria-hidden="true"
     data-bs-backdrop="static" data-bs-keyboard="false">
  <div class="modal-dialog modal-lg modal-dialog-centered modal-dialog-scrollable" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">高级搜索</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="col-12 col-lg-4">
            <div class="mb-3">
              <label class="form-label">类型</label>
              <select class="form-select" id="advanced_search_type">
                <option value="" selected>全部</option>
                <option value="电影">电影</option>
                <option value="电视剧">电视剧</option>
              </select>
            </div>
          </div>
          <div class="col-12 col-lg-4">
            <div class="mb-3">
              <label class="form-label required">名称</label>
              <input type="text" value="" id="advanced_search_name" class="form-control"
                     placeholder="电影/电视剧名称">
            </div>
          </div>
          <div class="col-12 col-lg-2">
            <div class="mb-3">
              <label class="form-label">年份</label>
              <input type="text" value="" id="advanced_search_year" class="form-control" placeholder="20xx">
            </div>
          </div>
          <div class="col-12 col-lg-2">
            <div class="mb-3">
              <label class="form-label">季</label>
              <select class="form-select" id="advanced_search_season">
                <option value="" selected>全部</option>
                {% for i in range(1, 51) %}
                  <option value="{{ i }}">第{{ i }}季</option>
                {% endfor %}
              </select>
            </div>
          </div>
        </div>
        <div class="row">
          <div class="col-12 col-lg-4">
            <div class="mb-3">
              <label class="form-label">站点</label>
              <select class="form-select" id="advanced_search_site">
                <option value="" selected>全部</option>
                {% for site in Indexers %}
                  <option value="{{ site.name }}">{{ site.name }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-12 col-lg-4">
            <div class="mb-3">
              <label class="form-label">质量</label>
              <select class="form-select" id="advanced_search_restype">
                <option value="" selected>全部</option>
                {% for Restype in RestypeDict %}
                  <option value="{{ Restype }}">{{ Restype }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-12 col-lg-4">
            <div class="mb-3">
              <label class="form-label">分辨率</label>
              <select class="form-select" id="advanced_search_pix">
                <option value="" selected>全部</option>
                {% for Pix in PixDict %}
                  <option value="{{ Pix }}">{{ Pix }}</option>
                {% endfor %}
              </select>
            </div>
          </div>
          <div class="col-12 col-lg-4">
            <div class="mb-3">
              <label class="form-label">促销</label>
              <select class="form-select" id="advanced_sp_state">
                <option value="* *" selected>全部</option>
                <option value="1.0 1.0">普通</option>
                <option value="1.0 0.0">免费</option>
                <option value="2.0 1.0">2X</option>
                <option value="2.0 0.0">2X免费</option>
                <option value="1.0 0.5">50%</option>
                <option value="2.0 0.5">2X 50%</option>
                <option value="1.0 0.7">70%</option>
                <option value="1.0 0.3">30%</option>
              </select>
            </div>
          </div>
          <div class="col-12 col-lg-8">
            <div class="mb-3">
              <label class="form-label">过滤规则</label>
              <select id="advanced_search_rule" class="form-control"></select>
            </div>
          </div>
        </div>
      </div>
      <div class="modal-footer">
        <button onclick="search_media_advanced()" id="search_advanced_btn"
                class="btn btn-primary">开始搜索
        </button>
      </div>
    </div>
  </div>
</div>
<!-- 用户认证 -->
<div class="modal modal-blur fade" id="modal-user-auth" tabindex="-1" role="dialog" aria-hidden="true">
  <div class="modal-dialog modal-md modal-dialog-centered" role="document">
    <div class="modal-content">
      <div class="modal-header">
        <h5 class="modal-title">用户认证</h5>
        <button type="button" class="btn-close" data-bs-dismiss="modal" aria-label="Close"></button>
      </div>
      <div class="modal-body">
        <div class="row">
          <div class="mb-3">
            <label class="form-label">合作站点</label>
            <select type="text" class="form-select" id="user_auth_site" onchange="switch_cooperation_sites(this)">
              {% for SiteId, SiteAttr in CooperationSites.items() %}
                <option value="{{ SiteId }}" data-custom-properties="&lt;span class=&quot;avatar avatar-xs&quot; style=&quot;background-image: url({{ SiteAttr.icon }})&quot;&gt;&lt;/span&gt;">{{ SiteAttr.name }}</option>
              {% endfor %}
            </select>
          </div>
        </div>
        {% for SiteId, SiteAttr in CooperationSites.items() %}
        <div class="row user_auth_params" id="user_auth_{{ SiteId }}_params" style="{% if loop.index0 != 0 %}display:none{% endif %}">
          {% for ParamId, ParamAttr in SiteAttr.params.items() %}
          {% if ParamAttr.name %}
          <div class="col-12 col-lg">
            <div class="mb-3">
              <label class="form-label">{{ ParamAttr.name }} <span class="form-help"
                                                               title="{{ ParamAttr.tooltip }}"
                                                               data-bs-toggle="tooltip">?</span></label>
              <input type="{{ ParamAttr.type }}" id="{{ SiteId }}_{{ ParamId }}" class="form-control" placeholder="{{ ParamAttr.placeholder }}">
            </div>
          </div>
          {% endif %}
          {% endfor %}
        </div>
        {% endfor %}
      </div>
      <div class="modal-footer">
        <button type="button" class="btn btn-link link-secondary me-auto" data-bs-dismiss="modal">取消</button>
        <button type="button" class="btn btn-primary" id="user_auth_btn" title="认证" onclick="user_auth()">
          认证
        </button>
      </div>
    </div>
  </div>
</div>
<cmd-dialog theme="light"></cmd-dialog>
<!-- 载入tabler组件 -->
<script src="../static/js/tabler/tabler.min.js"></script>
<script src="../static/js/tabler/libs/dropzone-min.js"></script>
<script src="../static/js/tabler/libs/list.min.js"></script>
<script src="../static/js/tabler/libs/tom-select.base.min.js"></script>
<script src="../static/js/tabler/demo.min.js"></script>
<!-- 载入业务脚本 -->
<script src="../static/js/util.js"></script>
<script src="../static/js/functions.js"></script>
<!-- 载入自定义组件 -->
<script src="../static/components/index.js"></script>
<!-- 首页事件  -->
<script type="text/javascript">

  // 页面初始事件
  $(document).ready(function () {

    // 监听页面状态
    window.addEventListener('popstate', function(e) {
        if (e.state) {
          // 开始还原页面
          if (e.state.CurrentPage) {
            sessionStorage.CurrentPage = e.state.CurrentPage;
          }
          CurrentPageUri = e.state.page;
          document.querySelector("#navbar-menu").update_active();
          $(window).unbind('scroll');
          document.title = e.state.title;
          $('#page_content').html(e.state.html).ready(function() {
            $(window).scrollTop(e.state.scroll);
          })
        }
    });

    // 浏览器关闭事件
    window.addEventListener("beforeunload", function() {
      // 关闭连接
      stop_message();
      stop_logging();
      stop_progress();
    });

    // tooltip点击事件处理，阻止冒泡到上级元素，避免比如`点击tooltip切换了switch`的问题
    $('body').on('click', 'span[data-bs-toggle="tooltip"]', function (e) {
      e.preventDefault();
      e.stopPropagation();
    });

    // 全局变量默认值
    DefaultTransferMode = '{{ SyncMod }}';
    DefaultPath = "{{ DefaultPath }}";

    // TomSelect下拉框
    init_tomselect();

    // Dropzone配置
    init_dropzone();

    // WebSocket刷新消息中心
    connect_message();

    {% if not TMDBFlag %}
      // 检查tmdb配置
      show_init_alert_modal();
    {% elif current_user.level == 1 %}
      // 用户认证
      show_user_auth_modal();
    {% endif %}

  });

</script>

<!-- KBar -->
<script type="text/javascript">
  const dialog = document.querySelector('cmd-dialog');
  const theme = localStorage.getItem("tablerTheme");
  if (theme) {
    dialog.theme = theme;
  }
  dialog.actions = [
    {% for Menu in Menus %}
      {% if Menu.page %}
        {
          id: '{{ Menu.page }}',
          title: '{{ Menu.name }}',
          img: `{{ Menu.icon|safe }}`,
          onAction() {
            navmenu('{{ Menu.page }}');
          },
        },
      {% elif Menu.list %}
        {% for SubMenu in Menu.list %}
          {% if SubMenu.page %}
            {
              id: '{{ SubMenu.page }}',
              title: '{{ SubMenu.name }}',
              img: `{{ SubMenu.icon|safe }}`,
              onAction() {
                navmenu('{{ SubMenu.page }}')
              },
            },
          {% endif %}
        {% endfor %}
      {% endif %}
    {% endfor %}
  ];
</script>

<!-- 用户自定义CSS -->
<style>
  {{ CustomScriptCfg.css|safe or "" }}
</style>

<!-- 用户自定义JavaScript -->
<script type="text/javascript">
  {{ CustomScriptCfg.javascript|safe or "" }}
</script>

</body>
</html>
